#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,cnt;
struct trn{
	int d,v,a;
}cr[100002],k;
int speed2(int pre,int add,int tim){
	if(add==0)return pre*pre;
	return pre*pre+2*add*pre*tim+add*add*tim*tim;
}
int mn[100002];
bool out[100002];
int main(){
	//Do not forget to freopen!
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	for(cin>>T;T;T--){
		cin>>n>>m>>L>>V;
		V=V*V;
		for (int i=1;i<=n;i++){
			cin>>cr[i].d>>cr[i].v>>cr[i].a;
		}
		cnt=0;
		memset(out,0,sizeof(out));
		for(int i=1;i<=m;i++){
			cin>>mn[i];
			for (int j=1;j<=n;j++){
				k=cr[j];
				if(k.d<=mn[i]&&!out[j]&&k.v+k.a*(mn[i]-k.d)>0&&speed2(k.v,k.a,mn[i]-k.d)>V){
					cnt++;
					out[j]=true;
				}
			}
		}
		cout<<cnt<<" "<<m-(cnt==0?0:1)<<"\n";
	}
	return 0;
}
